{
  "properties" : { },
  "id" : "76e9364cd7d54370a76ffaa46590b4ca",
  "script" : null,
  "groupId" : "98b0445b7653484aa929aa88f56cb7a8",
  "name" : "执行对话",
  "createTime" : 1741019539814,
  "updateTime" : 1741367987694,
  "lock" : null,
  "createBy" : null,
  "updateBy" : null,
  "path" : "doChat",
  "description" : null,
  "returnType" : null,
  "mappingPath" : null,
  "parameters" : [ {
    "name" : "body",
    "value" : null,
    "description" : "请求的参数",
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }, {
    "name" : "userId",
    "value" : null,
    "description" : "用户id",
    "required" : false,
    "dataType" : "String",
    "type" : "java.lang.Number",
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  } ]
}
================================
import cn.dev33.satoken.stp.StpUtil
import log
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import java.time.LocalDateTime;
import '@/ai/coze' as coze

//发送给智能体的内容
var sendContent = ""
if (body.sence_pid == 3) {
    sendContent = "我们是热恋的情侣，我想用" + body.sence_name + "风格。"
} else {
    sendContent = body.sence_p_name + "-" body.sence_name
}
if (body.type = 1) { //回答
    sendContent = sendContent + "怎么回答对方的话。对方原话：" + body.content
} else if (body.type = 2) {
    sendContent = sendContent + "怎么问对方：" + body.content
} else {
    sendContent = sendContent + "对这种话怎么回答：" + body.content
}
log.info("sendContent value-->" + sendContent);

var insertId = db.table("chat_record").insert({
    userId,
    type: body.type,
    sence_pid: body.sence_pid,
    sence_id: body.id,
    content: body.content,
    lastContent: sendContent,
    createBy: userId,
    createDate: now(),
})

//请求智能体
let result = coze(sendContent)
log.info("result-->" + result)
if (result != null) {
    db.table("chat_record").primary("id").update({
        id: insertId,
        ai_status: result.data.status, //更新状态
        conversation_id: result.data.conversation_id,
        chat_id: result.data.id,
    })
    return {
        id: insertId,
        conversation_id: result.data.conversation_id,
        chat_id: result.data.id,
    }
}